package com.cheng.operation.impl;

import com.cheng.common.exception.CommonException;
import com.cheng.data.entity.GvmtTypeInfEntity;
import com.cheng.operation.GvmtTypeInfOperation;
import com.cheng.service.GvmtTypeInfService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: ChengJW
 * @date: 2021/11/8 20:13
 * @version: 1.0
 * @description: 有关管辖机关信息表 gvmt_type_inf 表的业务逻辑操作
 */
@Service
public class GvmtTypeInfOperationImpl implements GvmtTypeInfOperation {

    private final static Logger log = LoggerFactory.getLogger(GvmtTypeInfOperationImpl.class);

    @Autowired
    private GvmtTypeInfService gvmtTypeInfService;

    /**
     * @author: ChengJW
     * @params: [entity]
     * @return: java.util.List<com.cheng.data.entity.GvmtTypeInfEntity>
     * @date: 2021/11/8
     * @description: 查询 gvmt_type_inf 列表信息
     */
    @Override
    public List<GvmtTypeInfEntity> queryGvmtTypeInf(GvmtTypeInfEntity entity) throws CommonException {
        return gvmtTypeInfService.queryGvmtTypeInf(entity);
    }

    /**
     * @author: ChengJW
     * @params: [code]
     * @return: java.lang.String
     * @date: 2021/11/8
     * @description: 根据管辖机关代码查询管辖机关名称
     */
    @Override
    public String queryGvmtTypeInfNmByCode(String code) throws CommonException {

        GvmtTypeInfEntity entity = new GvmtTypeInfEntity();
        entity.setGtTypeCode(code);
        List<GvmtTypeInfEntity> list = gvmtTypeInfService.queryGvmtTypeInf(entity);
        String gtTypeNm = "";
        if (null != list && list.size() > 0){
            gtTypeNm = list.get(0).getGtTypeNm();
        }
        return gtTypeNm;
    }


}
